module CommonStuff

 def parse_message(message)
    puts "==Parsing message:",message
    har=message[/\*.*\@.*\*/]
    if har!=nil
      har2=har[1..-2]
      if har2!=nil
        arr=har2.split('@')
        puts "3:",arr[0]
        puts "4:",arr[1]
      end
    end
    puts "1:",har
    puts "2:",har2
    return arr
  end

  def save_in_done(interval,e,done_date)
      puts "=====",__method__,"====="

      stats=GithubStat.where("story_id=?",e.story_id)
      code_addition=0
      code_deletion=0
      stats.each do |s|
        code_addition+=s.addition
        code_deletion+=s.deletion
      end

      done=Done.new
      done.p_entry_id=e.id
      done.story_id  =e.story_id
      done.story_name=e.story_name
      done.story_description=e.story_description
      done.story_type=e.story_type
      done.project_id=e.project_id
      done.project_name=e.project_name
      done.ptracker_token=e.token
      done.done_date=done_date
      done.time_cost=interval.to_s
      done.code_addition=code_addition
      done.code_deletion=code_deletion
      done.save!
    end


end